<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;

    }

    #app {
        padding: 0 0.8rem;
    }

    .order {
        width: 100%;
    }

    .order_item {
        padding: 0 0.4rem;
        margin-bottom: 0.5rem;
        /* height: 21.5rem; */
        background-color: #fff;
        box-shadow: 0px 0.1rem 0.7rem 0px rgba(0, 0, 0, 0.07);
        padding-bottom: 1rem;
    }

    .order_item_title {
        height: 2.1rem;
        width: 100%;
        border-bottom: 1px solid #eaeaea;
        color: #838383;
        font-size: 0.7rem;
        line-height: 2.2rem;
    }

    .order_item_title .time {
        float: left;
    }

    .order_item_title .statu {
        float: right;
        color: #555555;
        font-size: 0.6rem;
    }

    .order .order_item_main {
        height: 5rem;
        width: 100%;
        border-bottom: 1px solid #eaeaea;
    }

    .order .order_item_main p {
        margin-top: 0.3rem;
        font-size: 0.6rem;
        color: #555555;
    }

    .order_detail {
        width: 100%;
        height: 2rem;
    }

    .order_detail div {
        margin: 0.7rem 0.7rem 0.7rem 0;
        float: right;
    }

    .detail_btn {
        width: 4rem;
        height: 1.5rem;
        border: 1px solid #2780e8;
        color: #2780e8;
        font-size: 0.6rem;
        text-align: center;
        line-height: 1.5rem;
        border-radius: 0.75rem;
        box-sizing: border-box;
    }

    .del_btn {
        width: 4rem;
        height: 1.4rem;
        background-color: #878787;
        color: #fff;
        font-size: 0.6rem;
        text-align: center;
        line-height: 1.5rem;
        border-radius: 0.75rem;
        box-sizing: border-box;
    }

    .detail_btn_pay {
        width: 4rem;
        height: 1.5rem;
        background-color: #2780e8;
        color: #fff;
        font-size: 0.6rem;
        text-align: center;
        line-height: 1.5rem;
        border-radius: 0.75rem;
    }

    .none {
        font-size: 0.6rem;
        margin: 1rem 0;
        text-align: center;
    }
</style>

<body>
    <div  id="app" v-cloak>
        <div class="placeholder_div"></div>


        <div class="order" v-for="item in order_list">
            <div class="order_item">
                <div class="order_item_title">
                    <p class="time">下单时间：{{item.createTimeFormat}}</p>
                    <p class="statu" v-if="item.orderStatus == 1">待付款</p>
                    <p class="statu" v-if="item.orderStatus == 2">待发货</p>
                    <p class="statu" v-if="item.orderStatus == 3">待收货</p>
                    <p class="statu" v-if="item.orderStatus == 4">已完成</p>
                    <p class="statu" v-if="item.orderStatus == 5">已关闭</p>
                </div>
                <div class="order_item_main">
                    <p class="consignee">收货人：{{item.addressConsignee}}</p>
                    <p class="pharmacy_place">药 房：{{item.store}}</p>
                    <p class="num">帖 数：{{item.quantity}}</p>
                    <p class="price">价 格：{{item.drugMoney}}</p>
                </div>

                <div class="order_detail">
                    <!-- <div v-if="item.orderStatus == 1" class="detail_btn_pay" @click="go_pay(item.id)">去付款</div> -->
                    <!-- <div class="del_btn" @click="del_order(item.id)">删除</div> -->
                    <div class="detail_btn" @click="go_order_detail_win(item.id)">查看详情</div>

                </div>
            </div>

        </div>

        <p class="none">已经没有更多了~</p>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();

        getData()
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            page: 1,
            order_list: [],
            doctorId: $api.getStorage("emp").userId,
        },
        methods: {
            del_order: function (id) {
                get_ajax("order/findOrderDetailByDoctorId", {
                    doctorId: $api.getStorage("emp").userId,
                    orderId: id
                }, function (res, err) {
                    if (res.code == 200) {
                        if (res.data) {
                            get_ajax("order/delete", {
                                userId: res.data.userId,
                                orderId: id,
                            }, function (res, err) {
                                if (res.code == 200) {
                                    toast("删除成功")
                                }
                            })
                        }
                    }
                })
            },
            go_order_detail_win: function (id) {
                api.openWin({
                    name: "order_detail_win",
                    url: "order_detail_win.html",
                    pageParam: {
                        orderId: id,
                        doctorId: app.doctorId,
                    }
                })
            },
            go_pay: function (id) {

            }
        },

    })

    function getData() {
        get_ajax("order/listPageOrderByDoctor", {
            doctorId: app.doctorId,
            page: app.page,
            pagesize: 10,
        }, function (res, err) {
            // alert(JSON.stringify(res))

            if (res.code == 200) {

                app.order_list = res.data.data

                app.$nextTick(function () {
                    hb_init_openwinby_click();
                })
            }
            // } else {
            //     toast("网络不通畅，请稍后再试！")
            // }
            if (err) {
                // alert("网络不通畅，请稍后再试！")
            }
        })
    }
</script>